package com.linjing.item.service;

import com.linjing.item.model.ItemBo;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Value;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author 仇冬林
 * @date 2022/5/7
 */

@Slf4j
@DubboService(group = "common", version = "1.0")
public class ItemServiceImpl implements ItemService {

    @Value("${server.port}")
    private String port;
    InetAddress inetAddress;

    public ItemServiceImpl() throws UnknownHostException {
        inetAddress = InetAddress.getLocalHost();
    }

    public String addItem(ItemBo itemBo) {
        log.info("item: {}", itemBo);
        return "create ok : " + itemBo.getId() + "server port: " + inetAddress.getHostAddress() + ":" + port;
    }
}
